﻿<%@ Page language="c#" Codebehind="Set.aspx.cs" AutoEventWireup="false" Inherits="UDS.SubModule.WorkAttendance.Set" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta name="author" content="Herry" />
<meta name="Copyright" content="Copyright (c) 2009 himm.cn" />
<title>Set</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link rel="stylesheet" type="text/css" href="/css/other.css" media="screen" />
<script language="JavaScript" type="text/javascript" src="/Commons/DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="/css/table.css" />
		<script language="JavaScript" src="/Css/meizzDate.js"></script>
		<script language="javascript">
		function fillstring(str)
		{
			if(str.length==1)
			{
				str = "0" + str; 
			}
			return(str);
		}
		function quickseldate(type)
		{
			var begintime,endtime;
			var oneminute = 60*1000;
			var onehour   = 60*oneminute;
			var oneday    = 24*onehour;
			var oneweek   = 7*oneday;
			
			var todayDate = new Date();
			var date = todayDate.getDate();
			var month= todayDate.getMonth() +1;
			var year= todayDate.getYear();
			var day = todayDate.getDay();
			if(navigator.appName == "Netscape")
			{
				year = 1900 + year;
			}

			//-->
						
			if(type=="day")
			{
				begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
				endtime = begintime;
			}
			else if(type=="week")
			{
				var daytoMon = day-1;
				if(day==0) 
					daytoMon = 6;
				
				todayDate.setTime(todayDate.getTime()-daytoMon*oneday);
				date = todayDate.getDate();
				month= todayDate.getMonth() +1;
				year= todayDate.getYear();
				day = todayDate.getDay();
				
				begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
				
				todayDate.setTime(todayDate.getTime()+6*oneday);
				
				date = todayDate.getDate();
				month= todayDate.getMonth() +1;
				year= todayDate.getYear();
				
				endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
			}
			else if(type=="month")
			{
				var dateto1 = date-1;
				
				todayDate.setTime(todayDate.getTime()-dateto1*oneday);
				date = todayDate.getDate();
				month= todayDate.getMonth() +1;
				year= todayDate.getYear();
				day = todayDate.getDay();
				
				begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
				
				todayDate.setMonth(month);
				todayDate.setTime(todayDate.getTime()-oneday);
				
				date = todayDate.getDate();
				month= todayDate.getMonth() +1;
				year= todayDate.getYear();
				
				endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());

			}

			document.getElementById("txtbegintime").value = begintime;
			document.getElementById("txtendtime").value = endtime;
		
		}
		function checkdutytime(source,arguments)
		{
			var ondutytime,offdutytime;
			var begindate,enddate;
			ondutytime = document.getElementById('tbx_OnDutyTime').value;
			offdutytime = document.getElementById('tbx_OffDutyTime').value;
			begindate = Date.parse('1/1/1900 '+ondutytime);
			enddate = Date.parse('1/1/1900 '+offdutytime);
			if(enddate<begindate)
				arguments.IsValid = false;
			else
				arguments.IsValid = true;
		}
		function checkdutydate()
		{
			var begindate,enddate;
			begindate = document.getElementById('txtbegintime').value;
			enddate = document.getElementById('txtendtime').value;
			if(begindate.replace(' ','')=='' || enddate.replace(' ','')=='')
			{
				alert('日期不能为空');
				return false;
			}
			else
			{
				if(begindate>enddate)
				{
					alert('开始时间不能大于结束时间');
					return false
				}
			}
			return true;
		}
		</script>
</head>
	<body>
<form id="Set" method="post" runat="server">
<div class="m">
<p class="path"><a href="/SubModule/UnitiveDocument/">我的桌面</a> >> 考勤设置</p>
<div class="con">
<table bordercolor="#337FB2" border="1">
    <tr>
        <td style="width:90px; ">考勤日设置：</td>
        <td class="tl">开始时间：
            <asp:textbox id="txtbegintime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" cssClass="Wdate" runat="server"></asp:textbox> 结束时间：
            <asp:textbox id="txtendtime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" cssClass="Wdate" runat="server"></asp:textbox>&nbsp;
            <asp:comparevalidator id="cvdate" runat="server" ControlToCompare="txtbegintime" Operator="GreaterThanEqual"
                ErrorMessage="结束时间应该大于开始时间" ControlToValidate="txtendtime" Display="None"></asp:comparevalidator>&nbsp;
            <asp:radiobutton id="rbtnthisweek" onclick="quickseldate('week');" runat="server" GroupName="quickdate" Text="本周"></asp:radiobutton><asp:radiobutton id="rbtnthismonth" onclick="quickseldate('month');" runat="server" GroupName="quickdate" Text="本月"></asp:radiobutton><input language="javascript" class="buttoncss" id="btnsetdate" title="设置考勤日期" onclick="if (checkdutydate())  window.open('ShowDay.aspx?begintime='+document.Set.txtbegintime.value+'&amp;endtime='+document.Set.txtendtime.value,'_blank','menubar=no,location=no,toolbar=no'); " type="button" value="详细情况" name="btnsetdate" runat="server"></td>
    </tr>
    <tr>
        <td>设置考勤时间：</td>
        <td class="tl">上班时间：<asp:textbox id="tbx_OnDutyTime" runat="server" CssClass="txt" Columns="10"></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator3" runat="server" ErrorMessage="上班时间不能为空" ControlToValidate="tbx_OnDutyTime" Display="Dynamic"></asp:requiredfieldvalidator><asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" ErrorMessage="时间格式错误" ControlToValidate="tbx_OnDutyTime" Display="Dynamic" ValidationExpression="(((0|1)[0-9])|(2[0-3])|([0-9])):([0-5][0-9])"></asp:regularexpressionvalidator> 下班时间：
                <asp:textbox id="tbx_OffDutyTime" runat="server" CssClass="txt" Columns="10"></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator4" runat="server" ErrorMessage="下班时间不能为空" ControlToValidate="tbx_OffDutyTime" Display="Dynamic"></asp:requiredfieldvalidator><asp:regularexpressionvalidator id="RegularExpressionValidator2" runat="server" ErrorMessage="时间格式错误" ControlToValidate="tbx_OffDutyTime" Display="Dynamic" ValidationExpression="(((0|1)[0-9])|(2[0-3])|([0-9])):([0-5][0-9])"></asp:regularexpressionvalidator><asp:customvalidator id="CustomValidator1" runat="server" ErrorMessage="下班时间不能早于上班时间" Display="Dynamic" ClientValidationFunction="checkdutytime"></asp:customvalidator>（时间格式采用09:00或9:00） <asp:button id="btn_SetTime" runat="server" CssClass="buttoncss" Text=" 保  存"></asp:button></td>
    </tr>
    </table>
  </div>
</div>
</form>
</body>
</html>
